import numpy as np

array1 = np.array([[1, 2, 3, 4], [5, 6, 7, 8], [11, 22, 33, 44], [55, 66, 77, 88]])
# print(array1)
# array1 = array1.astype('int')
# print(array1)
#
# # 需求1：获取第二行数据
# print(array1[1])
#
# # 需求2：获取第三行第二列的值
# print(array1[2][1])
#
# print('*' * 50)
# 需求：获取33，44，77，88这四个元素
print(array1, type(array1))
print(array1[2:, 2:])
# array1[2:, 2:] = 0
# print(array1)
print(array1.shape)
print(type(array1[array1 > 22]))

array1 = array1[:2, :2]
print(array1)

array2 = np.array([[1, 2, 3, 4, 5, 6, 7], [11, 22, 33, 44, 55, 66, 77], [111, 222, 333, 444, 555, 666, 777],
                   [11, 12, 13, 14, 15, 16, 17], [21, 22, 23, 24, 25, 26, 27]])
print(array2)
print('*' * 50)
# 取出前4行和前4列
# array2 = array2[:4, :4]
# print(array2)
# print(np.split(array2, 3))
print(np.split(array2, [3, -1]))
# print(np.reshape(array2, (7, 5)))
# print(np.vstack((array2[1], array2[4])))
# print(np.hstack((array2[1], array2[1])))

# 矩阵转置的两种方式
# print(np.transpose(array2))
# print(array2.T)
# 左右反转
# print(np.fliplr(array2))
print(np.flipud(array2))

array1 = np.array([[1, 2, 3], [4, 5, 6]])
array2 = np.array([[10, 10, 10], [10, 10, 10]])

print(array1 + array2)
print(array1 - array2)
print(array1 * array2)
print(array1 // array2)

array1 = np.array([[100, 100]])

print(np.log(array1))
print(np.log10(array1))

np.random.seed(666)
print(np.random.rand(3, 3))
